<?php 
use \PsiFramework\Classes\Util\UI\Printer;
use \PsiFramework\Classes\Util\UI\HTML;
use \PsiFramework\Plugins\Shop\Classes\Model\Order;

$orders = $response->getAttribute("orders");
?>
<article id="cont-princ" class="nocols">
    <h1><?php Printer::display($languageManager->getText('PAST_ORDERS')); ?></h1>
    <div id="monPanier" class="fiche">
        <?php
        if (count($orders)==0) {
            Printer::display($languageManager->getText('NO_ORDERS'));
        } else {
        ?>
        <table>
            <thead class="tableTete">
				<tr>
					<th class="col0 tableTitre"></th>
					<th class="col1 tableTitre"><?php Printer::display($languageManager->getText('ORDER_DATE')); ?></th>
					<th class="col2 tableTitre"><?php Printer::display($languageManager->getText('ORDER_NUMBER')); ?></th>
					<th class="col3 tableTitre"><?php Printer::display($languageManager->getText('STATUS')); ?></th>
					<th class="col4 tableTitre"><?php Printer::display($languageManager->getText('TOTAL')); ?></th>
					<th class="tableTitre">&nbsp;</th>
					<th class="tableTitre">&nbsp;</th>
				</tr>
			</thead>
			<tbody>
			    <tr>
					<td class="sep" colspan="7"></td>
				</tr>
			<?php 
			$i=1;
            foreach ($orders as $order) {
                if ($order->isPaid()) {
            ?>
                <tr>
                    <td class="col0 tableTexte">
                        <?php Printer::display($i); ?>
                    </td>
                    <td class="col1 tableTexte">
                        <?php echo HTML::link($order->getDate(), 'action=ShowInvoice&order_id='.$order->getId()); ?>
                    </td>
                    <td class="col2 tableTexte">
                        <?php echo HTML::link($order->getNumber(), 'action=ShowInvoice&order_id='.$order->getId()); ?>
                    </td>
                    <td class="col3 tableTexte">
                        <?php
                        $statusCodeInfo = Order::getStatusCodeInformation($order->getStatus());
                        echo HTML::link($languageManager->getText($statusCodeInfo['description']), 'action=ShowInvoice&order_id='.$order->getId());
                        ?>
                    </td>
                    <td class="col4 tableTexte">
                        <?php echo HTML::link(number_format($order->getTotal(), 2, '.', ''), 'action=ShowInvoice&order_id='.$order->getId()); ?>
                    </td>
        			<td class="print">
        			    <a
        			        href="javascript:window.open('<?php echo HTML::linkHref('action=PrintShowInvoice&order_id='.$order->getId()); ?>', 'Facture', 'menubar=no, status=no, width=700, height=900');"
        			        title="<?php Printer::display($languageManager->getText('PRINTABLE_VERSION')); ?>">
        			        <img src="Images/AlloMedia/ico/ico_print.png" />
        		        </a>
        		    </td>
        			<td class="pdf">
        			    <a
        			        href="<?php echo HTML::linkHref('action=PdfShowInvoice&order_id='.$order->getId()); ?>"
        			        title="<?php Printer::display($languageManager->getText('DOWNLOAD_PDF')); ?>">
        			        <img src="Images/AlloMedia/ico/ico_pdf.png" />
        		        </a>
        		    </td>
                </tr>
                <tr>
					<td class="sep" colspan="5"></td>
				</tr>
            <?php
                    $i++;
                }
            }
            ?>
			</tbody>
			<tfoot></tfoot>
		</table>
		<?php 
        }
        ?>
	</div>
</article>
